<%@page isELIgnored="false" pageEncoding="UTF-8" contentType="text/html; UTF-8" %>
<html>
<head>
    <title>Title</title>
    <script src="layui/layui.js"></script>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="js/jquery-1.8.3.js"></script>
</head>
<body>
    <table id="adminLog" lay-filter="adminLog"></table>

    <script type="text/html" id="adminId">
        {{  d.admin.username  }}
    </script>
    <script type="text/html" id="delete">
        <a class="layui-btn layui-btn-lg" lay-event="delete">删除选中</a>
    </script>
    <script>
        layui.use(['table'],function () {
            var table = layui.table;

            table.render({
                elem:"#adminLog",
                page:true,
                url:"adminLog/selectAll",
                limit:5,
                limits:[5,8,10],
                toolbar:"#delete",
                cols:[[
                    {type:"checkbox"},
                    {title:"编号",field:"id"},
                    {title:"时间",field:"date"},
                    {title:"管理员",templet:"#adminId"},
                    {title:"内容",field:"content"},
                    {title:"类型",field:"type"},
                    {title:"IP地址",field:"ip"}
                ]]
            })
            table.on('toolbar(adminLog)',function (obj) {
                var check = table.checkStatus(obj.config.id);
                if(obj.event == 'delete'){
                    var arr = check.data;
                    var ids = [];
                    for(var i = 0;i<arr.length;i++){
                        ids.push(arr[i].id);
                    }
                    $.ajax({
                        url:"adminLog/deleteAll",
                        data:"ids="+ids,
                        dataType:"json",
                        success:function (result) {
                            if(result.isDelete){
                                table.reload('adminLog',{
                                    page:{
                                        curr:1
                                    }
                                });
                            }
                        }
                    })
                }
            })
        })
    </script>
</body>
</html>
